﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dotNetInteropPlugin.PluginDev;

namespace ManagedTestPlugin2
{
    public partial class ConfigTestForm : Form
    {
        public ConfigTestForm()
        {
            InitializeComponent();
        }


        public IMAIMPPlayer player
        {
            get;
            set;
        }

        public void Initialize(IMAIMPPlayer pl)
        {
            player = pl;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (!player.ConfigurationManager.IsSectionExist(textBox1.Text))
            {
                textBox3.Text = "";
                lblSpec.Text = "нет секции";
                return;
            }

            string v = player.ConfigurationManager.ReadParameterString(textBox1.Text, textBox2.Text);
            if (v != null)
            {
                textBox3.Text = v;
                lblSpec.Text = "OK";
            }
            else
            {
                textBox3.Text = "";
                lblSpec.Text = "не найдено";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(textBox4.Text) && !string.IsNullOrWhiteSpace(textBox5.Text) && !string.IsNullOrWhiteSpace(textBox6.Text))
            {
                player.ConfigurationManager.WriteParameter(textBox6.Text, textBox5.Text, textBox4.Text);
            }
        }
    }
}
